#include "Stdafx.h"
#include "Lua_CFunction.h"
#include "LuaFunctionEditer.h"
#include <QtCore/QFileInfo>

namespace BatchRename
{
	int CreateGUID(lua_State* L)
	{
		std::string guid = BaseFunction::CreateGUID();
		lua_pushstring(L, guid.substr(1, guid.length() - 2).c_str());
		return 1;
	}

	int FileDirtory(lua_State* L)
	{
		QString tFileFullPath = LuaFunctionRule::Single().CurrentFileFullPath();
		QString result = QFileInfo(tFileFullPath).absolutePath();
		lua_pushstring(L, result.toStdString().c_str());
		return 1;
	}

	int FileName(lua_State* L)
	{
		QString tFileFullPath = LuaFunctionRule::Single().CurrentFileFullPath();
		QString result = QFileInfo(tFileFullPath).completeBaseName();
		lua_pushstring(L, result.toStdString().c_str());
		return 1;
	}

	int FileSuffix(lua_State* L)
	{
		QString tFileFullPath = LuaFunctionRule::Single().CurrentFileFullPath();
		QString result = QFileInfo(tFileFullPath).suffix();
		lua_pushstring(L, result.toStdString().c_str());
		return 1;
	}
}